#include "cs2nuclTest.h"

using namespace std;

/* Test init */
Color2NucleotideTest::Color2NucleotideTest()
{
}

void Color2NucleotideTest::setUp()
{
}

void Color2NucleotideTest::tearDown()
{
}

/* Reminder letter coding:
    0:A
    1:C
    2:G
    3:T
*/
/* Testcases */
void Color2NucleotideTest::testConv()
{
	string colorS="T2112322311010133121320003202203201302321";
	// Expected: "CACT AGAT GTTG GTAT GACG AAAA TCCT CCGA ACGG ATCA";
	DnaSeq refNuclS={0,40, {0xd1, 0xc8, 0xbe, 0xce, 0x92, 0x00, 0xd7, 0x25, 0xa4, 0x1c}};
	DnaSeq nuclS;
	string str="";
	char buf[50];
	int cnt[]={0,0,0,0};

	CPPUNIT_ASSERT( color2Nucleotide(colorS, nuclS, (colorS.length()-1), cnt) == 0 );
	CPPUNIT_ASSERT( nuclS.flag == 0 );
	CPPUNIT_ASSERT( nuclS.len == 40 );
	bool eqStr=true;
	for (int i=0; i < ((nuclS.len+3) >> 2); i++) {
		if (nuclS.nucl[i] != refNuclS.nucl[i]) {
			eqStr = false;
			break;
		}
	}
	CPPUNIT_ASSERT( eqStr == true );
	CPPUNIT_ASSERT( cnt[(int)Nucl('A')] == 13);
	CPPUNIT_ASSERT( cnt[(int)Nucl('C')] == 9);
	CPPUNIT_ASSERT( cnt[(int)Nucl('G')] == 9);
	CPPUNIT_ASSERT( cnt[(int)Nucl('T')] == 9);
}

/* Testcases */
void Color2NucleotideTest::testConvWithDot()
{
	string colorS="T211232231101013312.320003202203201302321";
	DnaSeq nuclS;
	int cnt[]={0,0,0,0};

	CPPUNIT_ASSERT( color2Nucleotide(colorS, nuclS, (colorS.length()-1), cnt) == 1 );
}

/* Testcases */
void Color2NucleotideTest::testConvBadPrefix()
{
	string colorS="A2112322311010133121320003202203201302321";
	DnaSeq nuclS;
	int cnt[]={0,0,0,0};

	CPPUNIT_ASSERT( color2Nucleotide(colorS, nuclS, (colorS.length()-1), cnt) == 1 );
}

/* Testcases */
void Color2NucleotideTest::testConvLenError()
{
	string colorS="T2112322311010133121320003202203201302321";
	DnaSeq nuclS;
	int cnt[]={0,0,0,0};

	CPPUNIT_ASSERT( color2Nucleotide(colorS, nuclS, (colorS.length()), cnt) == 1 );
}

